import Vue from 'vue';
import axios from '@/utils/axios'
import {
    SUBJECT_TYPE
} from "@/config/enum";


Vue.mixin({
    filters: {
        fmtSubjectType(val) {
            return ['单选题', '多选题', '判断题', '简答题'][val]

        },
        fmtOrder2ABC(val) {
            return 'ABCDEFGHIJKLMNOPQRSTUVWYZ' [val]
        },
        fmtOrder2CN(val) {
            return '零一二三四五六七八九十' [val]
        }
    },
    data() {
        return {
            SUBJECT_TYPE
        };
    },
    methods: {
        async $get(url, params) {
            let {
                data
            } = await axios.get(url, {
                params
            })
            return data
        },
        async $post(url, param) {
            let {
                data
            } = await axios.$post(url, param)
            return data
        },
        checkArrayHasVal(arr){
            return arr && arr.length
        },
        checkIsXZT(type){
            return type===this.SUBJECT_TYPE.DANXUAN||type===this.SUBJECT_TYPE.DUOXUAN
        },
        checkIsNotJDT(type){
            return type!== this.SUBJECT_TYPE.JIANDA
        },
        $ms(str){
            this.$Message.success(str)
        },
        $mw(str){
            this.$Message.warning(str)
        },
        $me(str){
            this.$Message.error(str)
        },
    }
})